import Vue from 'vue'
import App from './App.vue'
import store from './store'
import router from './route'
import request from './utils/request'
import 'element-ui/lib/theme-chalk/index.css';
import {
  Notification,
  Message,
  Button,
  Table,
  Form,
  FormItem,
  Input,
  Row,
  Col,
  Image,
  Option,
  Select,
  Cascader,
  Radio,
  Popover,
  Divider
} from "element-ui"
Vue.use(Button); // Vue.component(Button.name,Button)
Vue.use(Table)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Input)
Vue.use(Row)
Vue.use(Col)
Vue.use(Image)
Vue.use(Option)
Vue.use(Select)
Vue.use(Cascader)
Vue.use(Radio)
Vue.use(Popover)
Vue.use(Divider)
Vue.config.productionTip = false
Vue.prototype.$notify = Notification;
Vue.prototype.$message = Message;
Vue.prototype.$request = request;
router.beforeEach((to, from, next) => {
  const path = to.path; // /manage/,/manage/home,/manage/user
  // 判断目标路由路径是否以/manage开头
  if (path.startsWith('/manage')) {
    if (store.getters['user/isLogin']) {
      next();
    } else {
      router.push('/login')
    }
  } else {
    // if (store.getters['user/isLogin']) {
    //   router.push('/manage/home')
    // } else {
    //   router.push('/login')
    // }
    next();
  }
})
new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')